Customizing Alert and Notification

The alert and notification system is built with an extensible architecture.

Adding New Periodic Alert

To add a custom alert, follow the below mentioned steps:

  1. Create a class library in .NET 8.0 version.
  2. Add a reference to below dlls. They are available  in common pvc mount path $common-volume-path/vanguard/extension folder.
    1. Quartz.dll
    2. Quartz.Serialization.Json.dll
    3. EV.AE.Vanguard.MonitorPeriodic.Core.dll
    4. EV.AE.Utilities.Logging.Core.dll
    5. EV.AE.Utils.Core.dll
    6. EV.AE.Utilities.Interfaces.Core.Vanguard
  3. Implement the abstract class PeriodicJobBase from EV.AE.Vanguard.MonitorPeriodic.Core.dll.
  4. Pass all the required dependencies of the job through constructor, declare all the dependencies as private read-only variables and extend PeriodicJobBase base class constructor with ILogging, IDAlClient, IServiceProvider, Itenant and IEnumerable<IAlertFormatter> dependency:

  5. Create the new class entry in product database by calling Create API. Refer API-docs. Class name must be same as “configurationName” in Json payload. Make sure that the “configurationValue” Json is valid.

  6. Refer API docs for sample JSON for the field “configurationValue”, below is the sample JSON.


    NOTE:

    In alertConfig and notifyContent, objects “name” ,“val”,and ”type” fields are mandatory. Also the value for each “name” field should be unique. 

  7. After adding this data using Post API call, you should be able to view alerts in Admin >Module Configuration-> Vanguard-> Alert Configuration tab as below.
    Click on Edit icon to enable / disable the alert.

    NOTE:

    Adding custom alert will require Vanguard pod restart.

  8. Details of the ExecuteJob Method.
    1. Input parameter (IJobExecutionContext context) – This is the configuration list and RepeatInterval provided in post Api Json payload. 

      To access configurations, use below sample.

    2. Output parameter (string) - The method returns a string with an alert description. This is an input to email notification.

      NOTE: 

      If there is no need to raise an alert, then return an empty string.

  1. Build the DLL in Release, AnyCPU mode. 
  2. Navigate to $common-volume-path/vanguard/extension folder and download the  EV.AE.Vanguard.Core.deps.json file. It is recommended to create a backup copy of this file before making any modifications.
  3. Update EV.AE.Vanguard.Core.deps.json with entries required for the new custom dll and its dependencies dlls. You can refer EV.AE.Vanguard.Monitor.PeriodicJobs.Core dll entry present in EV.AE.Vanguard.Core.deps.json file. Entries should be done in section:
    1. targets -> .NETCoreApp,Version=v8.0-> EV.AE.Vanguard.Core/1.0.0 -> dependencies
    2. targets -> .NETCoreApp,Version=v8.0
    3. libraries
  4. Place the DLL and updated EV.AE.Vanguard.Core.deps.json file at $common-volume-path/vanguard/extension folder. 
  5. Restart the Vanguard pod.

Adding new Formatter

By default, an email notification type is sent when an alert is raised. A custom formatter can also be configured. Follow the below steps to add a custom formatter.

  1. Create a class library in .NET core 8.0 version.
  2. Add a reference to below dlls. They are available at common pvc mount path “$common-volume-path/vanguard/extension” folder.
    1. EV.AE.Utilities.EntityModels.Core.dll
    2. EV.AE.Utilities.Interfaces.Core.dll
  3. Implement Interface IAlertFormatter in the class. It is present in namespace EV.AE.Utilities.Interfaces.Core.Vanguard.
  4. Create empty default constructor for formatter, create another parameterized constructor and pass all the required dependencies through this constructor, declare all the dependencies as private read-only variables.

  5. Class name must same as job “Formatter” in “formatter” key of “configurationValue” Json object as highlighted in below screenshot.

  6. IAlertFormatter interface contains a method ‘Format” as displayed.
    Details of the Format method:
    This method returns a list of the alerts for which notification is sent.
    1. Input parameter (string notifyContent) – This is “notifyContent” object passed in “configurationValue” json payload. Refer the above screenshot. You can use this object to extract notification related information.

    2. Input parameter (string alertDetail) – This is the content of the alert. For OOB alert, A JSON string is returned.
    3. Input parameter (string alertName) – This is the name of the triggered alert.
    4. Output parameter (List<SendItem>) - List of alerts to be sent.
  7. Build the DLL in Release, AnyCPU mode. Place the DLL at “$common-volume-path/vanguard/extension” folder. 
  8. Restart the Vanguard pod.

Updating OOB Email Template

Follow the below steps to update the OOB email template:

  • Download and update the file 
    • Download the $common-volume/vanguard/extension/Monitor/Formatter/Template file. 
    • Update the file
       “_CONTENT_TO_REPLACE_” must be present in the template. This text is replaced with the message body during runtime.
    • Place the updated file at $common-volume/vanguard/extension/Monitor/Formatter/Template location. 
    • Restart the Vanguard pod.

Adding new CRON Alert

To add a custom alert, follow the below mentioned steps:

  1. Create a class library in .NET core 8.0 version.
  2. Add a reference to below dlls. They are available  “ in common pvc mount path $common-volume-path/vanguard/extension folder.
    1. Quartz.dll
    2. Quartz.Serialization.Json.dll
    3. EV.AE.Vanguard.Cron.Core.dll
    4. EV.AE.Utilities.Logging.Core.dll
    5. EV.AE.Utilities.Interfaces.Core.Vanguard;
  3. Implement the abstract class CronJobBase from EV.AE.Vanguard.Cron.Core.dll. Pass all the required dependencies of the job through constructor, declare all the dependencies as private read-only variables and extend CronJobBase base class constructor with logging and tenant dependency.

  4. Ensure to ExecuteJob returns Task.CompletedTask and should not return null.
     

    NOTE: 

    • Make sure CRON expression should be valid.
    • Product recommends a Job that should have a higher interval for execution.  A job running at lower interval like seconds may rise issues with Product other bankground jobs execution.

  5. Build the DLL in Release, AnyCPU mode. 
  6. Navigate to $common-volume-path/vanguard/extension folder and download the  EV.AE.Vanguard.Core.deps.json file. It is recommended to create a backup copy of this file before making any modifications.
  7. Update EV.AE.Vanguard.Core.deps.json with entries required for the new custom dll and its dependencies dlls. You can refer EV.AE.Vanguard.Cron.Core.dll entry present in EV.AE.Vanguard.Core.deps.json file. 
    Entries should be done in section.
    1. targets -> .NETCoreApp,Version=v8.0 -> EV.AE.Vanguard.Core/1.0.0 -> dependencies
    2. targets -> .NETCoreApp,Version=v8.0
    3. libraries
  8. Place the DLL and updated EV.AE.Vanguard.Core.deps.json file at $common-volume-path/vanguard/extension folder. 
  9. Restart the Vanguard pod.
  10. To add a CRON job, invoke the BackgroundJob Create API to create a new job entry in the product database. For more details, see the product api docs.

  11. Invoke the search API to verify the newly created entry. For more details, see product api docs.